<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
        正则表达式:作用 快速对文本进行匹配 替换 查找


        */
      console.log("----------------修饰符---------------");
      //g:全局
      var str = "HelloWorld";
      var reg = /o/g; //正则表达式
      var result = str.match(reg);
      console.log(result);
      //i:忽略大小写
      var str = "HelloWOrld";
      var reg = /o/gi;
      var result = str.match(reg);
      console.log(result);
      var str = "lin1\nlin2";
      console.log(str);
      //m:多行匹配
      var reg = /^lin2/m;
      var result = reg.test(str);
      console.log(result);
      console.log("---------------[]---------------");

      var str = "E";
      //匹配任意一个
      // var reg = /[BCD]/;
      //[^B] 不是B
      var reg = /[^BCD]/;
      var result = reg.test(str);
      console.log(result);

      var str = "1";
      var reg = /[0-9]/;

      var result = reg.test(str);
      console.log(result);

      console.log("---------------元字符---------------");
      var str = "1";
      var reg = /\d/; //0-9
      var result = reg.test(str);
      console.log(result);

      var str = "}";
      var reg = /\w/; //字母数字下划线
      var result = reg.test(str);
      console.log(result);

      console.log("---------------量词---------------");
      /*
         *:0个或多个
         +:1个或多个
         ?:0个或1个
        */
      var str = "A1B1C1D";
      var result = str.split("1");
      console.log(result);
      var str = "A12B121321C11232D"; 
      var result = str.split(/\d+/) 
      console.log(result);
      var str = "AB2CD";
      var result = str.split(/\d*/)
      console.log(result);
      /*
       \d{6}
       \d{1,}
       \d{6,9}
      */
     var reg = /^1[35879]\d{9}$/
     var str = "13699175108";
     var result = reg.test(str);
     console.log(result);
     
      


    </script>
  </body>
</html>
